home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / basic / PureBasic_Upd.lha / PureBasic_Update1.60 / PureBasic / Examples / Sources / Joypad.pb < prev    next >
Encoding:
Text File  |  2000-09-10  |  1.2 KB  |  84 lines

  1. ;
  2. ; Joypad example for PureBasic !
  3. ;
  4.  
  5. If InitJoypad() = 0
  6.   PrintN("Can't use the joypads... Exit !")
  7.   End
  8. EndIf
  9.  
  10. PrintN("Move the joypad around, and push the buttons !")
  11.  
  12. a = 0
  13. Repeat
  14.   VWait()
  15.  
  16.   Printed = 0  ; To know if something is printed to the CLI.
  17.  
  18.   Result = JoypadMovement(1)
  19.  
  20.   If Result
  21.  
  22.     Select Result
  23.       Case 1
  24.         Print("Up ")
  25.  
  26.       Case 2
  27.         Print("Up-Left ")
  28.        
  29.       Case 3
  30.         Print("Left ")
  31.  
  32.       Case 4
  33.         Print("Down-Left ")
  34.  
  35.       Case 5
  36.         Print("Down ")
  37.  
  38.       Case 6         
  39.         Print("Down-Right ")
  40.  
  41.       Case 7
  42.         Print("Right ")
  43.  
  44.       Case 8
  45.         Print("Up-Right ")
  46.  
  47.     EndSelect
  48.  
  49.     Printed = 1
  50.   Endif
  51.  
  52.   Buttons.l = JoypadButtons(1)
  53.  
  54.   If Buttons
  55.  
  56.     If Buttons & #PB_JOYPAD_BUTTON1
  57.       Print("Button 1 ")
  58.       Printed = 1
  59.     EndIf
  60.  
  61.     If Buttons & #PB_JOYPAD_BUTTON2
  62.       Print("Button 2 ")
  63.       Printed = 1
  64.     EndIf
  65.   EndIf
  66.  
  67.   PressedKey = PressedRawKey()
  68.  
  69.   If PressedKey
  70.     Print("Keyboard has been pressed : ")
  71.     PrintNumber(PressedKey)
  72.     Printed = 1
  73.   EndIf
  74.  
  75.   If Printed    ; If something has been printed to the CLI, finish the line..
  76.     PrintN("")
  77.   EndIf
  78.  
  79.   a+1
  80. Until a>500
  81.  
  82. End
  83.  
  84.